package main.servlet.service.impl;

import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.List;

import main.pojo.User;
import main.servlet.service.OutputService;

public class OutputServiceImpl implements OutputService{
	SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
	
	@Override
	public void printUserTable(List<User> userList, PrintWriter writer) {
		
		writer.write("<h1>成功注册用户</h1>");
		writer.write("<table><tr><th>头像</th><th>用户名</th><th>工资</th><th>生日</th><th>性别</th></tr>");
		for(User user:userList){
			writer.write("<tr>");
//			writer.write("<td>NULL</td>");
			writer.write("<td>");
			
//			String imgStr = "<img src=\"ImageServlet?uname="+user.getUname()+"\">";
//			System.out.println(imgStr);
			
			writer.write("<img src=");
			writer.write("\"ImageServlet?uname=");
			writer.write(user.getUname());
			writer.write("\" style=\"width:80px;height:80px;\">");
			
			writer.write("</td>");
			writer.write("<td>"+user.getUname()+"</td>");
			writer.write("<td>"+user.getSal()+"</td>");
			writer.write("<td>"+format.format(user.getBirth())+"</td>");
			writer.write("<td>"+user.isSex()+"</td>");
			writer.write("</tr>");
		}
		writer.write("</table>");
		
	}	
}
